package com.iemes.controller.production;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iemes.controller.index.BaseController;
import com.iemes.entity.SchedulingFormMap;
import com.iemes.mapper.production.SchedulingMapper;
import com.iemes.mapper.production.WorkOrderMapper;
import com.iemes.util.Common;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.inject.Inject;
import java.util.List;

@Controller
@RequestMapping("/scheduling/")
public class SchedulingController  extends BaseController {

    @Inject
    private SchedulingMapper schedulingMapper;

    @RequestMapping("schedulingIndex")
    public String index(Model model){
        String[] btnArray = new String[]{"<button type=\"button\" id=\"addAccount\" class=\"btn btn-primary marR10\">新增</button>", "<button type=\"button\" id=\"editAccount\" class=\"btn btn-info marR10\">编辑</button>", "<button type=\"button\" id=\"delAccount\" class=\"btn btn-danger marR10\">删除</button>"};
        model.addAttribute("res", findByRes());
        model.addAttribute("btn", btnArray);
        return Common.BACKGROUND_PATH + "/production/scheduling/SchedulingIndex";
    }
    @RequestMapping("recordIndex")
    public String recordIndex(){
        return Common.BACKGROUND_PATH + "/production/scheduling/recordIndex";
    }

    @ResponseBody
    @RequestMapping("getSchPage")
    public PageInfo getWorkOrderPage(){
        PageHelper.startPage(1, 10);
        List<SchedulingFormMap> schedulingFormMaps = schedulingMapper.selSchPage();
        PageInfo pageInfo = new PageInfo<>(schedulingFormMaps);
        return pageInfo;
    }
    @ResponseBody
    @RequestMapping("getRecordPage")
    public PageInfo getRecordPage(){
        PageHelper.startPage(1, 10);
        List<SchedulingFormMap> schedulingFormMaps = schedulingMapper.selSchPage();
        PageInfo pageInfo = new PageInfo<>(schedulingFormMaps);
        return pageInfo;
    }

}
